<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户信息编辑页面</title>
<link rel="stylesheet" href="layui/css/layui.css" media="all">
<style>
.layui-btn:not(.layui-btn-lg ):not(.layui-btn-sm):not(.layui-btn-xs) {
	height: 34px;
	line-height: 34px;
	padding: 0 8px;
}
.layui-form-label {
 
    width: 100px;
 
}
</style>
</head>
<body>
	<form class="layui-form" action="">
	<div class="layui-form-item" style="margin-top: 20px;" onsubmit="false">
		<div class="layui-form-item" hidden="hidden">
			<label class="layui-form-label">用户ID:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="userid" name="userid" class="layui-input"
				lay-verify="required" lay-reqtext="用户ID获取失败"  hidden="hidden"	readonly="true">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">* </span>用户姓名:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="username" name="username" required=""
				 style="background:#ebebeb" lay-verify="required|username"
				 lay-reqtext="登录用户名不能为空" placeholder="请输入登录用户名"
					autocomplete="off" class="layui-input"  readonly="true">  
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">* </span>用户密码:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="userpassword" name="userpassword" required=""
					autocomplete="off" class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
		<input type="text" id="IsLockout2" hidden="hidden" />
			<label class="layui-form-label required"><span style="color: red;">* </span>是否禁用:</label>
			<div class="layui-input-inline">
				<input type="radio" name="IsLockout" value="1" title="启用" id="i1"> 
				<input type="radio" name="IsLockout" value="2" title="禁用" id="i2">
			</div>
		</div>
		
		
		<div class="layui-form-item">
			<label class="layui-form-label">最后登录时间:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="LastLoginTime" name="LastLoginTime" required=""
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">账户创立时间:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="CreateTime" name="CreateTime" required=""
					autocomplete="off" class="layui-input" readonly="true">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">* </span>密码错误次数:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="PsdWrongCount" name="PsdWrongCount" required=""
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">被锁定时间:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="LockTime" name="LockTime" required=""
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">* </span>密保邮箱:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="ProtectEmail" name="ProtectEmail" required="" lay-verify="required|email"
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span style="color: red;">* </span>密保手机号:</label>
			<div class="layui-input-inline" style="width: 500px;">
				<input type="text" id="ProtectTel" name="ProtectTel" required="" lay-verify="required|phone|number"
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-btn-container" style="text-align: center;">
			<button class="layui-btn" lay-filter="usersEditBtu" lay-submit="">
				修改</button>
		</div>
		</div>
	</form>
	<script type="text/javascript" src="layui/layui.js"></script>
	<script src="js/Global.js" type="text/javascript" charset="utf-8"></script>
	<script>
		//加载了layui的form模块
		layui.use([ 'form' ], function() {
			var form = layui.form,
			layer = layui.layer,
			$ = layui.$;
		form.verify({
		  username: function(value, item){ //value：表单的值、item：表单的DOM对象
		    if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
		      return '用户名不能有特殊字符';
		    }
		    if(/(^\_)|(\__)|(\_+$)/.test(value)){
		      return '用户名首尾不能出现下划线\'_\'';
		    }
		    if(/^\d+\d+\d$/.test(value)){
	      		return '用户名不能全为数字';
	    	}
	    
		    //如果不想自动弹出默认提示框，可以直接返回 true，这时你可以通过其他任意方式提示（v2.5.7 新增）
		    if(value === 'name'||value === 'username'||value === 'sb'){
		      return '用户名不能为敏感词';
		    }
		  }
		  
		  //我们既支持上述函数式的方式，也支持下述数组的形式
		  //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
		  ,pass: [
		    /^[\S]{6,12}$/
		    ,'密码必须6到12位，且不能出现空格'
		  ]
		});
		setTimeout(function(){
			if($("#IsLockout2").val()==1){
				$("#i1").attr("checked",true);
				 form.render('radio');
			}else if($("#IsLockout2").val()==2){
				$("#i2").attr("checked",true);
				 form.render('radio');
			}
		},200);
		//监听提交
			form.on('submit(usersEditBtu)', function(data) {
				var d = data.field; //表单中的数据，定义一个对象来接收
				d.method = "update";
				//通过ajax向数据库提交数据了
				console.log(d); //提交之前的一个数据验证、通过打印的方式先手动的去判断一下这个数据
				var url = globalData.server+'public/updateUsers';
				$.post(url, d, function(data) {
					if(data.count > 0) {
						var iframeIndex = parent.layer.getFrameIndex(window.name);
						parent.layer.close(iframeIndex);
					}
				}, "json");
				return false;
			});
		});
		layui.use('laydate', function() {
			var laydate = layui.laydate;
			//同时绑定多个时间选择器
			laydate.render({
				elem : '#LastLoginTime',
				type : 'datetime'
			});
			laydate.render({
				elem : '#CreateTime',
				type : 'datetime'
			});
			laydate.render({
				elem : '#LockTime',
				type : 'datetime'
			});
		});
	</script>
</body>
</html>